package com.efast.dmom.mgmt.controller.mes;



import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.efast.cafe.framework.bean.ResultBean;
import com.efast.dmom.mgmt.entity.mes.VinRule;
import com.efast.dmom.mgmt.service.mes.VinRuleService;

@Controller
@RequestMapping(value="/VinRule")
public class VinRuleController {
	@Autowired
	private VinRuleService vinRuleService;
	@RequestMapping(value="/getVinRuleInfo")
	public @ResponseBody ResultBean getVin() {
		ResultBean result = new ResultBean(true,"'");	
		String partNoVersion="TEST1116XV1-1116115-V1";
		int num=40;
		  List<String> listVin = vinRuleService.returnVinNum(partNoVersion,num);
		  result.setObject(listVin);
		return result;
	}
	
	@RequestMapping(value="/checkVin")
	public @ResponseBody ResultBean checkVin() {
		ResultBean result = new ResultBean(true,"'");	
		String partNoVersion="GK6800GBEV2-1101001-V1";
		String vin="LA9PDPZGXKY000001";
		Boolean checkVin = vinRuleService.checkVin(partNoVersion, vin);
		result.setObject(checkVin);
		return result;
	}
	
	@RequestMapping(value = "/saveRuleInfo", method=RequestMethod.POST)
	public @ResponseBody ResultBean saveRuleInfo(@RequestBody VinRule enti) {

		ResultBean result = new ResultBean(true, "'");
		result.setSuccess(true);
		ResultBean resultBean = vinRuleService.saveVinRuleInfo(enti);
		if(!resultBean.success) {
			result.setSuccess(false);
			result.setMessage(resultBean.message);
			return result;
		}
		return result;

	}
	
	@RequestMapping(value = "/deleteRuleInfo", method=RequestMethod.POST)
	public @ResponseBody ResultBean deleteRuleInfo(@RequestBody VinRule enti) {

		ResultBean result = new ResultBean(true, "'");
		result.setSuccess(true);
		vinRuleService.deleteVinRuleInfo(enti.getPartModelId());
		return result;
	}
}

